import request from '@/utils/request'

// 获取商品列表
export function getProductList(params) {
  return request({
    url: '/product/list',
    method: 'get',
    params
  })
}

// 创建商品
export function createProduct(data) {
  return request({
    url: '/product/create',
    method: 'post',
    data
  })
}

// 更新商品
export function updateProduct(data) {
  return request({
    url: '/product/update',
    method: 'post',
    data
  })
}

// 删除商品
export function deleteProduct(id) {
  return request({
    url: `/product/${id}`,
    method: 'delete'
  })
}

// 获取商品分类
export function getCategoryList() {
  return request({
    url: '/product/category/list',
    method: 'get'
  })
}

// 更新商品状态
export function updateProductStatus(id, status) {
  return request({
    url: '/product/status',
    method: 'post',
    data: { id, status }
  })
}

// 创建分类
export function createCategory(data) {
  return request({
    url: '/product/category/create',
    method: 'post',
    data
  })
}

// 更新分类
export function updateCategory(data) {
  return request({
    url: '/product/category/update',
    method: 'post',
    data
  })
}

// 删除分类
export function deleteCategory(id) {
  return request({
    url: `/product/category/${id}`,
    method: 'delete'
  })
}

// 获取库存记录
export function getStockList(params) {
  return request({
    url: '/product/stock/list',
    method: 'get',
    params
  })
}

// 更新库存
export function updateStock(data) {
  return request({
    url: '/product/stock/update',
    method: 'post',
    data
  })
}

// 获取库存预警列表
export function getStockAlertList() {
  return request({
    url: '/product/stock/alert',
    method: 'get'
  })
}

// 获取库存变动记录详情
export function getStockHistory(productId) {
  return request({
    url: `/product/stock/history/${productId}`,
    method: 'get'
  })
}

// 设置库存预警阈值
export function setStockAlert(data) {
  return request({
    url: '/product/stock/alert/set',
    method: 'post',
    data
  })
} 